package com.fortune.controller;

import com.faneui.common.exception.BusinessException;
import com.fortune.dal.dao.CardDAO;
import com.fortune.dal.model.BillInfo;
import com.fortune.service.BillInfoService;
import com.fortune.service.CustService;
import com.google.common.collect.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("creditcardbill")
public class CreditCardBillController extends AbstractController {

    @Autowired
    private CardDAO cardDAO;

    @Autowired
    private CustService custService ;

    @Autowired
    private BillInfoService billInfoService ;

    @RequestMapping(value = "", method = RequestMethod.GET)
    public ModelAndView indexOfAll() throws BusinessException {
        ModelAndView mv = new ModelAndView("creditcardbill");
        mv.addObject("menuFlag", "creditcardbill");
        return mv;
    }

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public List<BillInfo> list(@ModelAttribute BillInfo billInfo) throws BusinessException {
        List<BillInfo> list = null;
        try {
            billInfo.setType("1");
            list = billInfoService.queryBillInfoList(billInfo) ;
        } catch (Exception ex) {
            logger.error("", ex);
            return Lists.newArrayList();
        }
        return list;
    }

}
